<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Role List</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<link rel="stylesheet" type="text/css" href="<%=basePath%>basic/css/content.css" />
	<!-- 页面特效 -->
	<jsp:include page="/basic/res-refer/page-effect-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function addNewRole() {
  		loadNewModal(path+"basic/roleAction!queryRoleForManage.do?date="+new Date(),"Adding roles","260px","510px");
  	}
  	
  	function updateRole(roleUID) {
  		loadNewModal(path+"basic/roleAction!queryRoleForManage.do?roleUID="+roleUID+"&date="+new Date(),"Modify the role","260px","510px");
  	}
  	
  	function deleteRole(roleUID) {
  		Dialog.confirm("Are you sure to delete this role?", function() {
  			$.getJSON(path+"basic/roleActionJson!deleteRoleByRoleUID.do?date="+new Date(), {
  				roleUID: roleUID
  	  		}, function(data) {
  	  			if(data.success) {
  	  				Dialog.alert("Successful Operation！", function() {
  	  					window.location = path + "basic/roleAction!queryRoleList.do?date"+new Date();
  	  				});
  	  			} else {
  	  				Dialog.alert("System error, please contact adminitrator！");
  	  			}
  	  		});
  		});
  	}
  	
  	$(function(){
  		$("input[name='query']").click(function(){
  			var roleID = $("input[name='roleID']").val();
  			var roleName = $("input[name='roleName']").val();
  			window.location = path + "basic/roleAction!queryRoleList.do?roleID="+encodeURIComponent(roleID)+"&roleName="+encodeURIComponent(roleName)+"&date="+new Date();
  		});
  		$("input[name='add']").click(function(){
  			addNewRole();
  		});
  	});
  </script>
  <body>
  	<div class="content_all">
	  	<!--查询条件-->
	  	<div class="search">
	    	<form action=""><table cellpadding="0" cellspacing="0">
	      		<tr>
	        		<th>Role No.：</th>
			        <td><input name="roleID" value="<s:property value='roleID' />" type="text" class="s_input" /></td>
			        <th>Role Name：</th>
			        <td><input name="roleName" value="<s:property value='roleName' />" type="text" class="s_input" /></td>
			        <td><input name="query" type="button" value="Query" class="s_btn" />
			        	<input name="reset" type="reset" value="Reset" class="s_btn" />
	        			<input name="add" type="button" value="Add" class="s_btn" /></td>
	      		</tr>
	    	</table></form>
	  	</div>
	  	<!--查询列表-->
	  	<div class="search_table_all">
	    	<table class="search_table" cellspacing="0" cellpadding="0">
	      		<thead>
	        		<tr>
		          		<th style="width:50px;">Serial No.</th>
			          	<th>Role No.</th>
			          	<th>Role Name</th>
			          	<th>Rank</th>
			          	<th>Operation</th>
	        		</tr>
	      		</thead>
	      		<tbody>
	      			<s:iterator value="roleList" var="role" status="status">
	      				<tr>
		          			<td><s:property value="#status.index+1" /></td>
		          			<td><s:property value="#role.roleID" /></td>
		          			<td><s:property value="#role.roleName" /></td>
		          			<td><s:property value="#role.orderID" /></td>
		          			<td><a href="javascript:updateRole('<s:property value='#role.id' />')">[Modify]</a>&nbsp;&nbsp;
		          				<a href="javascript:deleteRole('<s:property value='#role.id' />')">[Delete]</a></td>
		        		</tr>
	      			</s:iterator>
	      		</tbody>
	    	</table>
	  	</div>
	</div>
  </body>
</html>
